package com.netposa.datawarehouse;

import com.ctrip.framework.apollo.spring.annotation.EnableApolloConfig;
import com.netposa.datawarehouse.aggregator.config.FeignClientConfiguration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.ApplicationPid;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.solr.SolrAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.system.ApplicationPidFileWriter;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.feign.EnableFeignClients;
import org.springframework.context.ApplicationListener;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.ComponentScan;

@EnableFeignClients(
   defaultConfiguration = {FeignClientConfiguration.class}
)
@EnableDiscoveryClient
@EnableApolloConfig
@ComponentScan(
   value = {"com.netposa.npwonder.base"},
   basePackageClasses = {AggregatorSearchApplication.class}
)
@SpringBootApplication(
   scanBasePackages = {"com.netposa"},
   exclude = {SolrAutoConfiguration.class}
)
public class AggregatorSearchApplication {
   private static final Logger log = LoggerFactory.getLogger(AggregatorSearchApplication.class);

   public static void main(String[] args) {
      ConfigurableApplicationContext context = (new SpringApplicationBuilder(new Object[0])).sources(new Class[]{AggregatorSearchApplication.class}).main(AggregatorSearchApplication.class).listeners(new ApplicationListener[]{new ApplicationPidFileWriter()}).run(args);
      log.info("----AggregatorSearchApplication Start PID={}----", (new ApplicationPid()).toString());
      context.registerShutdownHook();
   }
}
